<template>
  <div id="header-container">
    <div class="left-section">
      <span>天域北斗logo</span>
    </div>
    <div class="center-section">
      <span id="header-title">北京市防洪防汛平台</span>
    </div>
    <div class="right-section">
      <span style="margin-right: 1%">{{ currentDate }}</span>
      <span style="margin-right: 1%">{{ currentSecond }}</span>
      <span style="margin-right: 1%">{{ currentWeek }}</span>
    </div>
  </div>
</template>

<script setup>
import dayjs from 'dayjs'
import { ref, onMounted, computed, onUnmounted } from 'vue'

const timer = ref(null)
const weekMap = {
  Monday: '星期一',
  Tuesday: '星期二',
  Wednesday: '星期三',
  Thursday: '星期四',
  Friday: '星期五',
  Saturday: '星期六',
  Sunday: '星期日',
}

let currentDate = ref(dayjs().format('YYYY/MM/DD'))
let currentWeek = ref(weekMap[dayjs().format('dddd')])
let currentSecond = ref(dayjs().format('hh:mm:ss'))

onMounted(async () => {
  timer.value = setInterval(() => {
    currentDate.value = dayjs().format('YYYY/MM/DD')
    currentWeek.value = weekMap[dayjs().format('dddd')]
    currentSecond.value = dayjs().format('hh:mm:ss')
  }, 100)
})

onUnmounted(() => {
  timer.value && clearInterval(timer.value)
})
</script>

<style scoped>
#header-container {
  height: 12vh;
  width: 100%;
  padding: 0;
  margin: 0;
  background-image: url(../assets/uiResources/title.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.left-section {
  flex: 1;
  text-align: left;
  padding-left: 20px;
  color: white;
}

.center-section {
  padding-bottom: 2%;
  flex: 1;
  text-align: center;
  font-weight: bold;
}

.right-section {
  flex: 1;
  text-align: right;
  padding-bottom: 1%;
  padding-right: 1%;
  color: white;
}

#header-title {
  font-family: '等线Bold';
  font-size: 30px;
  font-stretch: normal;
  letter-spacing: 2px;
  /* 关键修改：添加文字渐变效果 */
  background: linear-gradient(to bottom, #ffffff, #a4f3ff, #3c70ff); /* 从上到下，白色到蓝色渐变 */
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 auto;
}

/* 保持原有的不可选属性 */
#header-container,
#header-container * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  pointer-events: none;
}
</style>
